﻿<h3><?php echo $this->translate('家庭成员') ?></h3>

<?php
if ( $this->familymembers ) {
  ?>
  <ul>
  <?php
  foreach( $this->familymembers as $user ): ?>
    <li>
      <?php echo $this->htmlLink($user->getHref(), $this->itemPhoto($user, 'thumb.icon'), array('class' => 'familymembers_thumb')) ?>
      <div class='familymembers_info'>
        <div class='familymembers_name'>
          <?php echo $this->htmlLink($user->getHref(), $user->getTitle()) ?>
        </div>
        <div class='familymembers_type'>
          <?php 
            $row = Engine_Api::_()->getDbTable('member', 'familymember')->fetchRow("resource_id = ".$this->subject()->getIdentity()." AND user_id = ".$user->getIdentity());
            if ( $row ) $type = Engine_Api::_()->getDbTable('type', 'familymember')->fetchRow("type_id = ".$row->type_id)->title;
            if ($type) echo $this->translate($type);
            
            if ( $row && $this->viewer()->isSelf($this->subject()) ) echo ' ('.$this->htmlLink( array('route'=>'default', 'module'=>'familymember', 'controller'=>'index', 'action' => 'edit', 'id' => $row->member_id), $this->translate('edit'), array('class' => 'smoothbox') ).')';
          ?>
        </div>
      </div>
    </li>
  <?php endforeach;
  ?>
  </ul>
  <?php
}
?>

<?php
  if ( $this->viewer()->getIdentity() ) {
    echo $this->htmlLink( array('route'=>'default', 'module'=>'familymember', 'controller'=>'index'), $this->translate('添加家庭成员') );
  }
?>